package com.ruoyi.web.tdmdata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdmdata.domain.TdmZhongShuShenJing;
import com.ruoyi.web.tdmdata.service.ITdmZhongShuShenJingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ID-05 -21 31 中枢神经系统药物Controller
 * 
 * @author ly
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tdmdata/TdmZhongShuShenJing")
public class TdmZhongShuShenJingController extends BaseController
{
    @Autowired
    private ITdmZhongShuShenJingService tdmZhongShuShenJingService;

    /**
     * 查询ID-05 -21 31 中枢神经系统药物列表
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmZhongShuShenJing tdmZhongShuShenJing)
    {
        startPage();
        List<TdmZhongShuShenJing> list = tdmZhongShuShenJingService.selectTdmZhongShuShenJingList(tdmZhongShuShenJing);
        return getDataTable(list);
    }

    /**
     * 导出ID-05 -21 31 中枢神经系统药物列表
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:export')")
    @Log(title = "ID-05 -21 31 中枢神经系统药物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmZhongShuShenJing tdmZhongShuShenJing)
    {
        List<TdmZhongShuShenJing> list = tdmZhongShuShenJingService.selectTdmZhongShuShenJingList(tdmZhongShuShenJing);
        ExcelUtil<TdmZhongShuShenJing> util = new ExcelUtil<TdmZhongShuShenJing>(TdmZhongShuShenJing.class);
        util.exportExcel(response, list, "ID-05 -21 31 中枢神经系统药物数据");
    }

    /**
     * 获取ID-05 -21 31 中枢神经系统药物详细信息
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmZhongShuShenJingService.selectTdmZhongShuShenJingById(id));
    }

    /**
     * 新增ID-05 -21 31 中枢神经系统药物
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:add')")
    @Log(title = "ID-05 -21 31 中枢神经系统药物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmZhongShuShenJing tdmZhongShuShenJing)
    {
        return toAjax(tdmZhongShuShenJingService.insertTdmZhongShuShenJing(tdmZhongShuShenJing));
    }

    /**
     * 修改ID-05 -21 31 中枢神经系统药物
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:edit')")
    @Log(title = "ID-05 -21 31 中枢神经系统药物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmZhongShuShenJing tdmZhongShuShenJing)
    {
        return toAjax(tdmZhongShuShenJingService.updateTdmZhongShuShenJing(tdmZhongShuShenJing));
    }

    /**
     * 删除ID-05 -21 31 中枢神经系统药物
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongShuShenJing:remove')")
    @Log(title = "ID-05 -21 31 中枢神经系统药物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmZhongShuShenJingService.deleteTdmZhongShuShenJingByIds(ids));
    }
}
